<template>
  <a-form
    id="components-form-demo-validate-other"
    :form="form"
    v-bind="formItemLayout"
    @submit="handleSubmit"
  >

  <!--业务办理单位（国有股东）-->
  <a-form-item label="业务办理单位（国有股东）">
    
    <!-- <a-form-item label="选择企业"> -->
       
          <a-tree-select
    v-model="value"
    style="width: 100%"
    :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
    :tree-data="treeData"
    placeholder=""
    tree-default-expand-all
  >
    <span v-if="key === '0-0-1'" slot="title" slot-scope="{ key, value }" style="color: #08c">
      Child Node1 {{ value }}
    </span>
  </a-tree-select>

    <!-- </a-form-item> -->
       <!-- <a-input-search placeholder="" @search="onSearch"> -->
       <!-- </a-input-search> -->
     
    </a-form-item>

  <!--统一社会信用代码-->
    <a-form-item label="统一社会信用代码">
      <a-input placeholder="" />
    </a-form-item>

    <!--决策程序-->
    <a-form-item label="决策程序" has-feedback>
      <a-select
        v-decorator="[
          'select',
          { rules: [{ required: true, message: 'Please select your country!' }] },
        ]"
        placeholder="---请选择---"
      >
        <a-select-option value="1">
          本经济行为已经国资监管机构银行相关决策程序
        </a-select-option>

        <a-select-option value="2">
          本经济行为已经国家出资企业履行相关决策程序
        </a-select-option>

        <a-select-option value="3">
          本经济行为已经国家出资企业子企业履行相关决策程序
        </a-select-option>

        <a-select-option value="4">
            本经济行为已经其他有权单位履行相关决策程序
        </a-select-option>

        <a-select-option value="5">
               本经济行为未履行相关决策程序
        </a-select-option>

        <a-select-option value="6">
              其他
        </a-select-option>
      </a-select>

    </a-form-item>


    <!--决策日期-->
    <a-form-item label="决策日期">
           <a-date-picker/>
    </a-form-item>

 <!--决策文件-->
  <a-form-item label="决策文件">
    <a-upload
      list-type="file"
      action="//jsonplaceholder.typicode.com/posts/"
      :preview-file="previewFile"
    >
      <a-button> <a-icon type="file" /> Upload </a-button>
    </a-upload>
    </a-form-item>

  <!--无经济行为决策文件理由描述-->
  <a-form-item label="无经济行为决策文件理由描述">
    
    <a-input placeholder="" />
    </a-form-item>

    <a-form-item :wrapper-col="{ span: 12, offset: 10 }">
      <a-button type="primary" html-type="submit">
        保存
      </a-button>
      <!-- #034789 -->
      <a-button type="primary" html-type="submit" style="margin-left:20px; background-color:#034789">
        重置
      </a-button>
       <a-button type="primary" html-type="submit" style="margin-left:20px">
        提交
      </a-button>
    </a-form-item>

  </a-form>
</template>

<script>

const treeData = [
  {
    title: '中国平煤神马能源化工集团有限责任公司',
    value: '0-0',
    key: '0-0',
    children: [
      {
        title: '神马实业股份有限公司',
        value: '0-0-1',
        key: '0-0-1',
      },

       {
        title: '平顶山天安煤业有限公司',
        value: '0-0-2',
        key: '0-0-2',
      },

      {
        title: '河南易成新能源股份有限公司',
        value: '0-0-3',
        key: '0-0-3',
      },
    ],
  }

];


export default {



  data: () => ({
      formItemLayout: {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 },
    },


  

      value: undefined,
      treeData,
  }),


  beforeCreate() {
    this.form = this.$form.createForm(this, { name: 'validate_other' });
  },
  methods: {
    handleSubmit(e) {
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
          console.log('Received values of form: ', values);
        }
      });
    },


previewFile(file) {
      console.log('Your upload file:', file);
      // Your process logic. Here we just mock to the same file
      return fetch('https://next.json-generator.com/api/json/get/4ytyBoLK8', {
        method: 'POST',
        body: file,
      })
        .then(res => res.json())
        .then(({ thumbnail }) => thumbnail);
    },

 

    normFile(e) {
      console.log('Upload event:', e);
      if (Array.isArray(e)) {
        return e;
      }
      return e && e.fileList;
    },
  },
};

</script>
<style>
#components-form-demo-validate-other .dropbox {
  height: 180px;
  line-height: 1.5;
}

</style>